package com.liu.educenter.controller;


import com.liu.commonutils.ReturnResult;
import com.liu.educenter.entity.UcenterMember;
import com.liu.educenter.entity.vo.LoginVo;
import com.liu.educenter.entity.vo.RegisterVo;
import com.liu.educenter.service.UcenterMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author LiuMeng
 * @since 2022-06-29
 */
@RestController
@RequestMapping("/educenter/member")
@CrossOrigin
@Api("登录注册功能")
public class UcenterMemberController {

    @Autowired
    UcenterMemberService ucenterMemberService;

    // 登录功能的实现
    @PostMapping("/login")
    @ApiOperation("登录注册")
    public ReturnResult login(@RequestBody LoginVo loginVo){
        String token = ucenterMemberService.login(loginVo);
        return ReturnResult.ok().data("token",token);
    }

    // 注册功能
    @PostMapping("/register")
    @ApiOperation("注册接口")
    public ReturnResult register(@RequestBody RegisterVo registerVo){
        ucenterMemberService.register(registerVo);
        return ReturnResult.ok();
    }

}

